﻿using LoveNote.Application.Picture.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TookKit.Mvvm.Attributes;
using TookKit.Mvvm.Enums;

namespace LoveNote.Application.Picture.Views
{
    [DependencyInjection(Lifetime.Singleton)]
    [View]
    public partial class PictureView : UserControl
    {
        public PictureView()
        {
            InitializeComponent();
        }

        private void CommandBinding_Paste(object sender, ExecutedRoutedEventArgs e)
        {
            if (DataContext is not PictureViewModel vm) 
                return;
            Image image = null;
            IDataObject dataObject = Clipboard.GetDataObject();
            if (dataObject.GetDataPresent(DataFormats.Bitmap))
            {
                image = (Image)dataObject.GetData(DataFormats.Bitmap);
            }
            else if (dataObject.GetDataPresent(DataFormats.EnhancedMetafile))
            {
                image = (Image)dataObject.GetData(DataFormats.EnhancedMetafile);
            }
            else if (dataObject.GetDataPresent(DataFormats.MetafilePicture))
            {
                image = (Image)dataObject.GetData(DataFormats.MetafilePicture);
            }
            else if (dataObject.GetDataPresent(DataFormats.Dib))
            {
                image = (Image)dataObject.GetData(DataFormats.Dib);
            }

        }

        private void PasteCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }

        private void PasteCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {

        }
    }
}
